package libs;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import bookException.BookException;
import bookException.BookExceptionCode;

public class ValidationMethods {
	
	public static boolean isValid(String field, BookException bookException, Pattern pattern) throws BookException{
		Matcher matcher = pattern.matcher(field);
		if (!matcher.matches())
			throw bookException;
		return true;
	}
	
	public static boolean isEmpty(String field, BookException bookException) throws BookException{
		if(field == null || field.isEmpty()) {
			  throw bookException;
		}
		return true;
	}
	
	public static boolean isEmpty(String field){
		if(field == null || field.isEmpty()) {
			  return true;
		}
		return false;
	}
}
